/**
 * @param {number[]} nums
 * @param {number} diff
 * @return {number}
 */
var arithmeticTriplets = function(nums, diff) {
    let i = 0, res = 0;
    while(i < nums.length - 2) {
        let j = 0, k = 0
        for(let h = i + 1; h < nums.length; h++) {
            if(!j && nums[h] === nums[i] + diff) {
                j = h
            }
            if(j && nums[h] === nums[i] + 2 * diff) {
                k = h
                res++
                break
            }
        }
        i++
    }
    return res;
};
console.log(arithmeticTriplets([0,1,4,6,7,10], 3));
console.log(arithmeticTriplets([4,5,6,7,8,9], 2));